<template>
  <!--第一次进来强制修改密码-->
  <div class="login">
    <p class="banner"><img src="../../assets/banner.png" alt="" width="100%"></p>
    <wv-group>
      <wv-input placeholder="请输入新密码" :type="type" class="pwd" v-model="password1">
        <img :src="src" alt="" slot="ft" @click="change" width="30">
      </wv-input>
      <wv-input placeholder="请确认新密码" :type="type1" class="pwd" v-model="password2">
        <img :src="src1" alt="" slot="ft" @click="change1" width="30">
      </wv-input>
    </wv-group>
    <wv-button type="primary" @click="goSubmit">确定</wv-button>
    <!-- &lt;!&ndash;销售端首页&ndash;&gt;
     <router-link to="/index" style="display: none"><wv-button type="primary">确定</wv-button></router-link>
     &lt;!&ndash;商家核销端首页&ndash;&gt;
     <router-link to="/shangjiaindex"><wv-button type="primary">确定</wv-button></router-link>-->
  </div>
</template>

<script type="text/ecmascript-6">
  import {resetpwd} from '../../../test/unit/http'
  import {getStore} from '../../../test/unit/storage'
  import {Toast} from 'we-vue'
  export default {
    name: 'firstlogin',
    props: {},
    data() {
      return {
        type: 'password',
        src: require('../../assets/bieye.png'),
        type1: 'password',
        src1: require('../../assets/bieye.png'),
        password1: "",
        password2: ""
      };
    },
    methods: {
      change(){
        this.type = this.type == 'password' ? 'text' : 'password';
        this.src = this.src == require('../../assets/eye.png') ? require('../../assets/bieye.png') : require('../../assets/eye.png')
      },
      change1(){
        this.type1 = this.type1 == 'password' ? 'text' : 'password';
        this.src1 = this.src1 == require('../../assets/eye.png') ? require('../../assets/bieye.png') : require('../../assets/eye.png')
      },
      goSubmit(){
        if (this.password1 != this.password2) {
          Toast.text("密码不一致");
          return;
        }
        let result=this.$myUtils.checkPwStrong(this.password2);
        if(!result){
          Toast.text("密码长度须大于6位且包含大小写字母");
          return;
        }
        let params = {
          password: this.password2
        };
        resetpwd(params).then(res => {
          console.log(res);
          if (res.code === 100) {
            let employeeType = getStore('employeeType');
            if (employeeType == "platform") {
              this.$router.push("/index")
            }
            if (employeeType == "shop") {
              this.$router.push("/shangjiaindex")
            }
            if (employeeType == "third") {
              this.$router.push("/shangjiaindex")
            }
          }
        })
      }
    },
    created() {

    },
    components: {}
  }
</script>


<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less" rel="stylesheet/less">
  .banner img {
    object-fit: cover;
  }

  .weui-btn_primary {
    background-color: #f98e3c;
    margin-top: 30px;
  }

  button.weui-btn {
    width: 94%;
    margin-top: 30px;
  }

  .weui-btn_primary a {
    color: #fff;
  }

  .weui-cell:before {
    right: 15px;
  }
</style>
